using System.Collections.Generic;

namespace OrderingSystem.API.Models
{
    /// <summary>
    /// 分页参数
    /// </summary>
    public class PageParams
    {
        private int _pageSize = 10;
        private int _pageNumber = 1;

        public int PageSize
        {
            get => _pageSize;
            set => _pageSize = value > 0 ? value : 10;
        }

        public int PageNumber
        {
            get => _pageNumber;
            set => _pageNumber = value > 0 ? value : 1;
        }
    }

    /// <summary>
    /// 分页工具类
    /// </summary>
    public static class PageUtils
    {
        public static object GetPageData<T>(IEnumerable<T> list, int total, PageParams pageParams)
        {
            return new
            {
                records = list,
                total = total,
                size = pageParams.PageSize,
                current = pageParams.PageNumber,
                pages = (total + pageParams.PageSize - 1) / pageParams.PageSize
            };
        }
    }

    /// <summary>
    /// 评价分页工具类
    /// </summary>
    public class ReviewPageUtils
    {
        public IEnumerable<object> list { get; set; }
        public int totalCount { get; set; }
        public int pageSize { get; set; }
        public int currPage { get; set; }
        public int totalPage { get; set; }
    }
} 